package besta.moon.sql.expression.function.time;

import besta.moon.sql.datatype.DateTime;
import besta.moon.sql.parser.SQLTokenizer;
import besta.moon.sql.expression.function.FunctionReturnInt;

public final class FunctionDayOfWeek extends FunctionReturnInt {

    @Override
    public final int getFunction() {
        return SQLTokenizer.DAYOFWEEK;
    }

    @Override
    public final int getInt() throws Exception {
        if (param1.isNull()) {
            return 0;
        }
        return DateTime.dayOfWeek(param1.getLong()) + 1;
    }

}
